import request from '@/utils/axios';
import {IUserInfo} from "@/redux/user/states";


/** 获取所有用户信息 GET /api/sys-user/allUser */
export async function allUser(options?: { [key: string]: any }) {
    return request<{
        data: API.SelectOptionUser[];
    }>('/api/sys-user/all-users', {
        method: 'GET',
        ...(options || {}),
    });
}

/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
    return request<Record<string, any>>('/api/login/outLogin', {
        method: 'POST',
        ...(options || {}),
    });
}

/**
 * 登录接口 POST /api/login/account
 * */
export async function login(body: API.LoginParams) {
    //  <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
    return request<'', IUserInfo>('/api/login/account', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        data: body,
    });
}

/** 注册接口 POST /api/login/account */
export async function register(body: API.UserRegisterParams, options?: { [key: string]: any }) {
    return request<'', API.LoginResult>('/api/register', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        data: body,
        ...(options || {}),
    });
}

/** 此处后端没有提供注释 GET /api/notices */
export async function getNotices(options?: { [key: string]: any }) {
    return request<API.NoticeIconList>('/api/approval-notify', {
        method: 'GET',
        ...(options || {}),
    });
}
